<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div.box{
            width:300px;
            height:300px;
            background-color: deeppink;
        }
        div.box2{
            padding:50px;
            font-size:30px;
            text-align: center;
        }

        div.box3{
            font-size:80px;
            text-align: right;
        }
    </style>

</head>
<body onload="initClass()">
    <div>
        93大阅兵
    </div>

    <script>
        //通过className为元素添加类样式
        function initClass(){
            //类样式
            //document.querySelector("div").className = "box box2";
            //一次性添加2个
            document.querySelector("div").classList.add("box","box2"); 
            //document.querySelector("div").classList.remove("box2","box")
             document.querySelector("div").classList.toggle("box3")
        }
    </script>
</body>
</html>